package com.cheng.xbjy.controller;

import com.cheng.xbjy.entity.vo.Result;
import com.cheng.xbjy.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/dept")
public class DeptController {

    @Autowired
    private DeptService deptService;

    /**
     * 查询所有部门
     *
     * @return
     */
    @GetMapping("")
    public Result findAll() {
        return new Result(true, "查询成功", deptService.findAll());
    }

    /**
     * 查询所有部门以及部门的员工
     * @return
     */
    @GetMapping("/findAllAndUser")
    public Result findAllAndUser() {
        List<Map<String, Object>> list = deptService.findAllAndUser();
        return new Result(true, "查询成功", list);
    }
}
